Skip to content

fix: repair failing tests and type errors across api and shared packages#58

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2475-1781580058
Open

fix: repair failing tests and type errors across api and shared packages#58
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2475-1781580058

Conversation

@stooit

@stooit stooit commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript type errors in the multi-package Bun + Hono API repo. bun test now reports 22 pass / 0 fail and tsc --noEmit is clean.

Changes

  • tsconfig.json — added "types": ["bun-types"] so tsc resolves bun:test and the process global (bun-types was already installed; no new dependency).
  • packages/shared/src/types.ts — renamed User.userNameusername to match the field name used by the route handlers and tests (cross-package field-name inconsistency).
  • packages/shared/src/utils/pagination.ts — implemented the paginate() stub: page slicing, total, totalPages (0 for empty input), echoed page/pageSize, and safe empty/out-of-range handling.
  • packages/api/src/middleware/auth.ts — fixed a case-sensitivity bug in the public-methods allow-list ("post""POST"); HTTP methods arrive uppercase, so POST /users was wrongly requiring a token. PUT/DELETE/PATCH still require a Bearer token (no security regression).
  • packages/api/src/routes/users.ts — added the missing badRequest import from ../lib/errors (was a runtime ReferenceError).

Verification

  • bun test → 22 pass, 0 fail (37 assertions)
  • bunx tsc --noEmit → clean, zero errors
  • No test files modified; no dependencies added.

Assumptions

  • The username (lowercase) field name is canonical, since the tests and route handlers use it and tests must not change.
  • Pagination requires no page clamping — Array.prototype.slice handles out-of-range pages gracefully and no test asserts clamping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant